﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Skynet.WebAdministracion.Views.WebAdmin
{
    public  class WebAdminPresenter  :  Infrastructure.Web.Views.Master.MasterPresenter<IWebAdminView>
    {
        public override void OnViewInitialized()
        {
                base.OnViewInitialized();
        }
        public override void OnViewLoaded()
        {
            base.OnViewLoaded();
        }
        public void EncryptConnectionString()
        {
            var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
            var csSection = config.ConnectionStrings;
            csSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
            csSection.SectionInformation.ForceSave  =  true;
            config.Save(System.Configuration.ConfigurationSaveMode.Modified);            
        }
        public void DecryptConnectionString()
        {
            var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
            var csSection = config.ConnectionStrings;
            csSection.SectionInformation.UnprotectSection();
            csSection.SectionInformation.ForceSave = true;
            config.Save(System.Configuration.ConfigurationSaveMode.Modified);            
        }
    }
}
